var async = require('async');
var ng = require('nodegrass');
var fn = require('./fn.js');
var fs = require('fs');
var plate;
var author;
var rs;
exports.rs;
exports.host;
exports.html;
exports.nextPage;
var thisurl;
var thisnextpagere;
var thisnextpagerem;
var thisnextPage;
var thisnn88 = new Array();
var thisnn888 = new Array();
var thisswfstr;
var tempnrarr = new Array();
var pagehtml = "";
var thisnopage=0;
var thisnonr=0;
var nopage=0;
var nonr=0;
var bianma="gbk";
var isgbk="";
var thissecexe;
var PUHUO=new Object();


exports.fxnews = function (url, comeback) {
    exports.url = url;
    thisurl = url;
    exports.baseurl = url;
    console.log(">>>>---"+url);
    file = "d:/temp/" + fn.substr(fn.preg_replace("\\:|\\/|\\?|\\=|\\&|\\-|\\%|\\;|\\-", "", url).replace(/-/g, ""), 0, 100);
    async.series({
            getRs: function (cb) {
                rssql = require("./zqnewsmysql");
                exports.host = fn.gethost(url);
                exports.host2 = fn.gethost2(url);
                nextpagerem = "";
                rssql.getrs(exports.host, function (result) {
                    result = (result == undefined) ? {} : result;
                    rs = exports.rs = result;
                    nextpage = "";
                    bianma=(rs.gbk==1||rs.gbk==="")?"gbk":"utf8";
                    if (fn.trim(exports.rs.nextpage) != "") {
                        cc = fn.preg_split("\\|\\|\\||[\\r\\n]+|$", exports.rs.nextpage);
                        for (irs = 0; irs < cc.length; irs++) {
                            if (fn.trim(cc[irs]) != "") {
                                nextpage += "|" + fn.trim(cc[irs]);
                                if (fn.preg_match("(?<!\\\\)\\(.*\\)", cc[irs])) {
                                    nextpagerem=nextpagerem.push(fn.trim(cc[irs]));
                                }
                            }
                        }
                    } else {
                        exports.rs.nextpage = "";
                        nextpagerem = new Array()
                    }
                    thisnextpagere = exports.rs.nextpage;
                    thisnextpagerem = nextpagerem;
                    cb();
                },exports.host2);
            },
            getHTML: function (cb) {
                var iconv = require('iconv-lite');
                var fs = require('fs');
                filename = "d:\\temp\\" + url.replace(/\/|\:|\?|\=|\&|\-|%|;|-/gi, "").replace(/\//, "\\").substring(0, 100);
                filename = filename.trim();
                if (!fs.existsSync(filename)) {
                    fn.getwrite(url,rs,function(data){
                        exports.html=data;
                        cb();
                    });
                }else if(fs.existsSync(filename)){
                    var fileStr = fs.readFileSync(filename, {encoding:'binary'});
                    var buf = new Buffer(fileStr, 'binary');
                    //re=/charset="(gbk|gb2312)"/gi
                    //if(re.test(buf)){
                        //var str = iconv.decode(buf, 'GBK');
                    //}else{
                        var str = iconv.decode(buf, 'utf8');
                    //}
                    //console.log(str);
                    exports.html = str;
                    cb();
                }
            },
            getMore: function (cb) {
                nn = new Array();
                exports.baseurl = "";
                thisbaseurl = "";
                if (fn.preg_match("/<base\\s+href=\"([^<>\\s]+)\"/isx", exports.html, nn)) {
                    if (nn.length > 0) {
                        exports.baseurl = nn[1];
                        thisbaseurl = exports.baseurl;
                    }
                }
                pagehtml = exports.html;
                if (rs.pre_delete != "") {
                    dd = fn.preg_split("/\\|\\|\\||[\\r\\n]+|$/m", fn.trim(rs.pre_delete));
                    for (p = 0; p < dd.length; p++) {
                        one = fn.trim(dd[p]);
                        if (fn.trim(one) == "" || fn.trim(one) == "@@") continue;
                        mm = fn.preg_split("/@@/", one);
                        mm[1] = (mm[1] == null) ? "" : mm[1];
                        pagehtml = fn.preg_replace("/" + mm[0] + "/Uisx", mm[1], pagehtml);
                    }
                }
                pagehtml = fn.preg_replace("/(desc|alt)=\"([^<>]*)\"/Uisxe", '"\\1=\"".fn.strip_tags3("\\2")."\""', pagehtml);
                pagehtml = fn.preg_replace("/点击图片进入下一(页|张)/Uisx", '', pagehtml);
                pagehtml = fn.preg_replace("/<(span|font)\\s+[^<>]*(display\\:none|class=\"jammer\"|color\\:\\#FFF)[^<>]*>[^<>]*<\/(span|font)>/Uisx", "", pagehtml);
                cb();

            },
            getTile: function (cb) {
                getsubject(function (subject) {
                    exports.subject = subject;
                    cb();
                });
            },
            getPlate: function (cb) {
                getPlate(exports.html, function (plate) {
                    exports.plate = plate;
                    cb();
                });
            },
            getDateLine: function (cb) {
                getDateLine(exports.html, function (dateline) {
                    exports.dateline = dateline;
                    cb();
                });
            },
            getAuthor: function (cb) {
                getAuthor(exports.html, function (author) {
                    exports.author = author;
                    cb();
                });
            },
            getContent: function (cb) {
                getContent(pagehtml, function (content) {
                    exports.message = content;
                    cb();
                });
            },
            getFenyue: function (cb) {
                getfenye(exports.html, function (url) {
                    exports.nextPage = url;
                    cb();
                });
            },
            three: function (cb) {
                result = {subject: exports.subject, message: exports.message, nextPage: exports.nextPage};
                comeback(result);
            }
        },
        function (err, results2) {
            // results is now equal to: {one: 1, two: 2,three:3}
            console.log("byebye");
        });

}

function getsubject(cb) {
    if (exports.rs == undefined) return;
    var subject = "";
    if (exports.rs.titlere != "") {
        dd = fn.preg_split("\\|\\|\\||[\\r\\n]+|$", exports.rs.titlere);
        for (i = 0; i < dd.length; i++) {
            onedd = dd[i];
            if (fn.trim(onedd) == "" || fn.trim(onedd) == "@@") continue;
            mm = fn.preg_split("@@", onedd);
            if (fn.preg_match("\\(.*\\)", mm[0])) {
                mm[0] = fn.trim(mm[0]);
                nn = Array();
                nn[1] = Array();
                fn.preg_match_all("" + fn.trim(mm[0]) + "", exports.html, nn);
                if (nn.length > 0 && fn.trim(subject) == "") {
                    subject = fn.trim(nn[1][0]);
                    break;
                }
            }
        }
    }

    if (subject == "") {
        nn = Array();
        fn.preg_match_all("<title>(.*)<\\/title>", exports.html, nn);
        if (nn.length > 0) {
            subject = fn.trim(nn[1][0]);
            subject = fn.strip_jscss(subject);
            subject = fn.preg_replace("\"", "\\\"", fn.strip_tags(subject)); //<img><p><br><td><table><tr><ul><li><span><script>
            subject = fn.preg_replace("(\\r|\\n)+|$", "", fn.trim(subject));
            subject = fn.preg_replace("\\&nbsp\\;|\\s+?", " ", subject);
            subject = fn.preg_replace("(_|\\-|\\-|\\—|－).*$", "", subject);
            subject = fn.preg_replace("(_|\\-|\\-|\\||\\s|\\—｜－).*(网|社区|论坛|行).*$", "", subject);
        }
    }
    if (fn.preg_match("\\/|404\\sNot\\sFoun|moved<|Access\\s+Denied|建议您使用|502\\s+Bad\\s+Gateway|400\\s+Bad|id=\\\"inhalt\\\"|Bad\\s+Request|found", subject)) {
        subject = "";
    }
    cb(fn.trim(subject));
}

function getPlate(pagehtml, comeback) {
    plate = "";
    if (plate == "") {
        if (plate == "") {
            nn = new Array();
            nn[1] = new Array();
            fn.preg_match_all("<title>[^<>\\-\\_]*(?:\\-|_|\\－)([^<>\\-\\_]*)(?:\\-|_|\\－)[^<>]*<\\/title>", pagehtml, nn);
            plate = nn[1][0];
        }
        if (fn.trim(plate) == "") {
            nn = new Array();
            fn.preg_match("<META\\s+name=\"source\"\\s+content=\"([\\u4e00-\\u9fa5A-Za-z0-9_]+)\">", pagehtml, nn);
            plate = fn.trim(fn.strip_tags(nn[1]));
        }
        if (fn.trim(plate) == "") {
            nn = new Array();
            fn.preg_match("mod=forumdisplay\\&amp\\;fid=[0-9]+\">(.*)<\\/a>\\s*<em>", pagehtml, nn);
            plate = fn.trim(fn.strip_tags(nn[1]));
        }

        if (fn.trim(plate) == "") {
            nn = new Array();
            fn.preg_match("<a\\s*href=\"[^<>]*\">([^<>]*)<\\/a>\\s*\\-?\\->\\s*正文", pagehtml, nn);
            plate = fn.trim(fn.strip_tags(nn[1]));
        }

        if (fn.trim(plate) == "") {
            plate = fn.tongx("版块,来源", pagehtml, 2);
        }

        if (fn.trim(plate) == "" && !fn.preg_match("/[\\u4e00-\\u9fa5]+", plate)) {
            plate = "";
        }
        plate = fn.preg_replace("\\(|\\)", "", plate);
        plate = fn.preg_replace("(\\-$|^\\-)", "", plate);
        plate = fn.preg_replace("^网\\-?", "", plate);
        plate = fn.trim(plate);
        comeback(plate);
    }
}

function getAuthor(pagehtml, comeback) {
    author = "";
    if (author == "") {
        if (author == "") {
            nn = new Array();
            fn.preg_match("<p\\s+class=\\\"red\\\"><strong>\\s*([\\u4e00-\\u9fa5A-Za-z0-9_]*)\\s*<\\/strong>", pagehtml, nn);
            author = fn.trim(fn.strip_tags(nn[1]));
        }
        if (author == "") {
            nn = new Array();
            fn.preg_match("\\b(?:uid|userid)\\b[^<>]+>([^<>]*)<\\/a>\\s*(<\\/strong>|<em>|<b>|\\&nbsp\\;|<img)", pagehtml, nn);
            author = fn.trim(fn.strip_tags(nn[1]));
        }
        if (author == "") {
            nn = new Array();
            fn.preg_match("username=([\\u4e00-\\u9fa5A-Za-z0-9_]*)\\\"", pagehtml, nn);
            author = fn.trim(fn.strip_tags(nn[1]));
        }
        if (author == "") {
            nn = new Array();
            fn.preg_match("回\s*([\\u4e00-\\u9fa5A-Za-z0-9_]*)\\s*的帖子", pagehtml, nn);
            author = fn.trim(fn.strip_tags(nn[1]));
        }
        if (author == "") {
            nn = new Array();
            fn.preg_match("给\\s*([\\u4e00-\\u9fa5A-Za-z0-9_]*)\\s*发送", pagehtml, nn);
            author = fn.trim(fn.strip_tags(nn[1]));
        }
        if (author == "") {
            nn = new Array();
            fn.preg_match("楼主<span>\\s*([\\u4e00-\\u9fa5A-Za-z0-9_]*)\\s*<\\/span>：", pagehtml, nn);
            author = fn.trim(fn.strip_tags(nn[1]));
        }
        if (author == "") {
            nn = new Array();
            fn.preg_match("title=\\\"(.*)\\\"\\s*alt=\\\"头像\\\"", pagehtml, nn);
            author = fn.trim(fn.strip_tags(nn[1]));
        }

        if (author == "") {
            nn = new Array();
            fn.preg_match("<div\\s*class=\\\"readName\\s*b\\\">\s*<a\\s+href=\\\"u\\/[0-9]+\\\">(.*)<\\/a>", pagehtml, nn);
            author = fn.trim(fn.strip_tags(nn[1]));
        }
        if (author == "") {
            nn = new Array();
            fn.preg_match("\\suid=\\\"[0-9]+\\\"\\s+uname=\\\"([^<>]*)\\\"", pagehtml, nn);
            author = fn.trim(fn.strip_tags(nn[1]));
        }
        if (fn.trim(author) == "") {
            fn.preg_match("<META\\s+name=\\\"author\\\"\\s+content=\\\"([\\u4e00-\\u9fa5A-Za-z0-9_]+)\\\">", pagehtml, nn);
            author = fn.trim(fn.strip_tags(nn[1]));
        }
        if (author == "") {
            nn = new Array();
            fn.preg_match("<span\\s+id=\\\"blognamespan\\\">([\\u4e00-\\u9fa5A-Za-z0-9_]+)<\\/span>", pagehtml, nn);
            author = fn.trim(fn.strip_tags(nn[1]));
        }
        if (author == "") {
            nn = new Array();
            fn.preg_match("本主题由(.*?)于", pagehtml, nn);
            author = fn.trim(fn.strip_tags(nn[1]));
        }
        if (author == "") {
            nn = new Array();
            if (fn.preg_match("添加(.*?)到好友列表", pagehtml, nn)) {
                author = fn.trim(fn.strip_tags(nn[1]));
            }
        }

        if (fn.trim(author) == "") {
            author = fn.tongx("作者,发布人,楼主", pagehtml, 2);
        }
        author = (author < 0 || author == "") ? "" : author;
    }
    comeback(author);
}

function getDateLine(pagehtml, comeback) {
    dateline = "";
    if (dateline == "") {
        if (dateline == "") {
            nn = new Array();
            nn[0] = new Array();
            fn.preg_match_all("\\b(?!\\/|\\-)(([0-9]{2}|(?:20|19)[0-9]{2}))[\\-\\.][0-9]{1,2}[\\-\\.][0-9]{1,2}[0-9\\-\\s\\:]*", pagehtml, nn);
            dateline = nn[0][0];
        }
        if (dateline == "") {
            nn = new Array();
            nn[0] = new Array();
            fn.preg_match_all("发表于\\s*<span\\s*title=\\\"(\\b[0-9]{2,4}\\-[0-9]{1,2}\\-[0-9]{1,2}[0-9\\-\s\\:]*)\\\">", pagehtml, nn);
            dateline = nn[1][0];
        }
        if (dateline == "") {
            nn = new Array();
            nn[0] = new Array();
            fn.preg_match_all("([0-9]{2}|[0-9]{4})年[0-9]{1,2}月[0-9]{1,2}日(\\s*[0-9]{1,2}\\s*\\:\\s*[0-9]{1,2}?)?", pagehtml, nn);
            dateline = nn[0][0];
        }
        if (dateline == "") dateline = fn.tongx("发表时间,发表日期,发布日期,发布日期,时间", pagehtml);
    }
    comeback(dateline);
}

function getContent(pagehtml, comeback) {
    var nn22 =new  Array();
    var nn44 =new  Array();
    var nn55 =new  Array();
    var nn66 =new  Array();
    var nn11 =new  Array();
    var nn111 =new  Array();
    var nn00 =new  Array();
    var nn222 =new  Array();
    var nn99 =new  Array();
    var nn88=new Array();
    var nn888=new Array();

   nn8888 = nn4444 = "";
    textarea = "";
    rs = exports.rs;

    if (rs.re != "") {
        cc = fn.preg_split("\\|\\|\\||[\\r\\n]+|$", fn.trim(rs.re));
        for (i = 0; i < cc.length; i++) {
            cc[i] = fn.trim(cc[i]);
            if (fn.trim(cc[i]) == "" || !fn.is_re(cc[i])) continue;
            tempnr = pagehtml;
            if (fn.preg_match("\\:y(?=$\\:)", fn.trim(cc[i]))) {
                cc[i] = fn.preg_replace("/\\:y(?=$|\\:)/", "", fn.trim(cc[i]));
                tempnr = pagehtml;
            }
            if (fn.preg_match("/\\:nn00/Uisx", fn.trim(cc[i]))) {
                exports.nopage = 1;
            } else {
                exports.nopage = 0;
            }
            if (fn.preg_match("\\:nn01", fn.trim(cc[i]))) {
                exports.nonr = 1;
            } else {
                exports.nonr = 0;
            }
            mm5 = new Array();
            if (fn.preg_match("/\\:to([a-z_]+)(?=\\:|$)/Uisx", fn.trim(cc[i]), mm5)) {
                temp = fn.preg_replace("/\\:to([a-z_]+)(?=\\:|$)/Uisx", "", fn.trim(cc[i]));
                mm6=new Array();
                mm6[1]=new Array();
                fn.preg_match_all(fn.trim(temp), tempnr, mm6);
                addreturn = new Array();
                addreturn[mm5[1]] = mm6[1][0];
            }
            //处理re
            if (!fn.preg_match("\\&\\&\\&", cc[i])) {
                mm4 = new Array();
                if (fn.preg_match("\\:nn([0-9]+?)(.*)$", fn.trim(cc[i]), mm4)) {
                    aann = new Array();
                    fn.preg_match("<([^<>]*)>", mm4[2], aann);
                    if (aann.length > 0) {
                        aaname = new Array();
                        aaname = aann[1];
                    }

                    //带有:nn的re
                    cc[i] = fn.preg_replace("\\:nn[0-9]+?(.*)$", "", fn.trim(cc[i]));
                    var tnnmm41 = new Array();
                    fn.preg_match_all(fn.trim(cc[i]), pagehtml, tnnmm41);
                    if (tnnmm41.length > 0 && tnnmm41[1].length > 0 && fn.trim(tnnmm41[1][0]) != "") {
                        console.log("A2nn:" + cc[i]);
                                    if (mm4[1] == "99" || mm4[1] == "22" || mm4[1] == "44" || mm4[1] == "221" || mm4[1] == "11") {
                                        dtmm=eval("nn"+mm4[1]);
                                        if(dtmm[1]==undefined||dtmm[1].length < tnnmm41[1].length){
                                            eval("nn"+mm4[1]+"=tnnmm41;");
                                        }
                                    } else if (mm4[1] == "88") {
                                       nn88.push(fn.trim(cc[i]));
                                       exports.nextPage = getNextPage(nn88, pagehtml);
                                    } else if (mm4[1] == "55") {
                                        nn55 = array_merge3(nn55, tnnmm41, aaname);
                                    } else if (mm4[1] == "66") {
                                        nn66 = array_merge4(nn66, tnnmm41, aaname);
                                    } else if (mm4[1] == "888" && (thisnn888==null||thisnn888==undefined)) {
                                        xx=new Array();
                                        if (fn.preg_match("/\((.*)\)$/Uisx", mm4[2], xx)) {
                                            cs = explode(",", xx[1]);
                                            cs[0] = fn.preg_replace("/(^\"|\"$)/", "", cs[0]);
                                            start = intval(fn.str_replace('"', "", cs[1]));
                                            end = tnnmm41;
                                            index = intval(fn.str_replace('"', "", fn.str_replace("\\", "", cs[2])));
                                            end = current(end[index]);
                                            style = fn.str_replace('"', "", cs[3]);
                                            nn888 = array();
                                            for (page = start; page <= end; page++) {
                                                pagestr = fn.str_replace("%", intval(fn.str_replace("\"", "", page)), style);
                                                nn888.push(fn.preg_replace("/"+cs[0]+"/Uisx", "\\1"+ $pagestr+"\\2", thisurl));
                                            }
                                            thisnn888 = nn888;
                                        }
                                    } else if (mm4[1] > 1000) {
                                        dtmm=eval("nn"+mm4[1]);
                                        eval("nn"+mm4[1]+"=fn.danweiarray(tnnmm41);");
                                    } else {
                                        tnnmm41 = (tnnmm41==undefined) ? array() : tnnmm41;
                                        dtmm=eval("nn"+mm4[1]);
                                        dtmm = (dtmm==null||dtmm==undefined || dtmm == "") ? [] :dtmm;
                                        eval("nn"+mm4[1]+"= fn.array_merge(dtmm, tnnmm41[1]);");
                                    }
                                    nopage[mm4[1]] = thisnopage;
                                    nonr[mm4[1]] = thisnonr;
                    }
                } else {
                    //        //一般的re
                    if (fn.trim(textarea) == "") {
                        cc[i] = fn.trim(cc[i]);
                        nn = new Array();
                        fn.preg_match_all(cc[i], tempnr, nn);
                        if (nn.length > 0 && fn.maxlen(fn.trim(nn[1][0])) > fn.maxlen(textarea)) { //####
                            console.log("A1:" + cc[i]);
                            textarea = fn.trim(nn[1][0]);
                            swfstr = "";
                            swf_replace(textarea, thisurl, swfstr);
                            PUHUO = {re: cc[i], value: textarea};
                        }
                    }
                }
            } else {
                ddd = fn.preg_split("&&&", cc[i]);
                tempnr = pagehtml;
                //带有&&&的re
                for (d = 0; d < ddd.length - 1; d++) {
                    nn = new Array();
                    nn[1] = new Array();
                    fn.preg_match_all("/" + fn.trim(ddd[d]) + "/Uisx", tempnr, nn);
                    //nn[1][0] = (nn['nr'][0]) ? nn['nr'][0] : nn[1][0];
                    if (fn.trim(nn[1][0]) == "") {
                        tempnr = "";
                        break;
                    } else {
                        //tempnr = (nn['value'][0]) ? nn['value'][0] : nn[1][0];
                        tempnr = nn[1][0];
                        for (j = 0; j < nn[1].length; j++) {
                            tempnrarr.push(nn[1][j]);
                        }
                    }
                }
                if (tempnr == "") continue;
                //带有&&&和:nn的re
                mm3 = new Array();
                mm3[1] = new Array();
                mm3[2] = new Array();
                if (fn.preg_match("/\:nn([0-9]+?)(.*$)/Uisx", fn.trim(ddd[ddd.length - 1]), mm3)) {
                    fn.preg_match("/<([^<>]*)>/Uisx", mm3[2], aann);
                    aaname =aann[1];
                    ddd[ddd.length - 1] = fn.preg_replace("/\\:nn[0-9]+?(.*$)/Uisx", "", fn.trim(ddd[ddd.length - 1]));
                    ccoldarr =new Array();
                    for (t = 0; t < tempnrarr.length; t++) {
                        if (fn.preg_match("/%%%/", ddd[ddd.length - 1])) {
                            console.log("B1:" + cc[i]);
                            //                tempnrarr=array();
                            //                oronerearr = fn.preg_split("/%%%/", fn.trim(ddd[ddd.length - 1]));
                            //                for (o = 0; o < count(oronerearr); o++) {
                            //                    fn.preg_match_all("/" . oronerearr[o] . "/Uisx", tempnr, nnoo);
                            //                    for (oo = 0; oo <= count(nnoo[1]); oo++) {
                            //                        if (nnoo['key'] != "") {
                            //                            $key = nnoo['key'];
                            //                        } else {
                            //                            $key = getKeyName(nnoo);
                            //                        }
                            //                        tempnrarr[getKeyName(nn)][getKeyName(nnoo)][] = fn.trim(nnoo[1][oo]);
                            //                    }
                            //                }
                            //                ${"nn" . mm3[1]} = tempnrarr;
                        } else {
                            tnnmm31 = new Array();
                            fn.preg_match_all("/" + fn.trim(ddd[ddd.length - 1]) + "/Uisx", tempnrarr[t], tnnmm31);
                            if (tnnmm31.length < 1) continue;
                            console.log("B2:" + cc[i]);
                            if(tnnmm31!=undefined&&tnnmm31.length<1){
                                tnnmm31 =new Array();
                                tnnmm31[1]=new Array();
                            }
                                            if (fn.trim(tnnmm31[1][0]) != "" || tnnmm31[1].length > 1) {
                                                if (mm3[1] == "99" || mm3[1] == "22" || mm3[1] == "44" || mm3[1] == "221" || mm3[1] == "11") {
                                                    eval("nn"+mm3[1]+" =tnnmm31;") ;
                                                } else if (mm3[1] == "88") {
                                                    if (!fn.in_array(fn.trim(cc[i]), ccoldarr)) {
                                                        nn88.push(fn.trim(cc[i]));
                                                        ccoldarr.push(fn.trim(cc[i]));
                                                        exports.nextPage = getNextPage(nn88, pagehtml);
                                                    }
                                                } else if (mm4[1] == "55") {
                                                    nn55 = fn.array_merge3(nnmm41, tnnmm31, aaname);
                                                } else if (mm4[1] == "66") {
                                                    nn66 = fn.array_merge3(nnmm41, tnnmm31, aaname);
                                                } else if (mm3[1] > 1000) {
                                                    nnmm31 = danweiarray(tnnmm31);
                                                } else {
                                                    nnmm31 = array_merge2(nnmm31, tnnmm31[1]);
                                                }

                                            }
                                            nopage[mm3[1]] = thisnopage;
                                            nonr[mm3[1]] = thisnonr;
                        }
                    }
                    //        $params = array("nn22" => nn22, "nn44" => nn44, "nn11" => nn11, "nn99" => nn99);
                    //        $tm = tnnmm31;
                    //        if (fn.trim(textarea) == "" && fn.maxlen(fn.trim($tm[1][0])) > fn.maxlen(textarea) && fn.is_zw($tm[1][0])) {
                    //            textarea = tempnr = $tm[1][0];
                    //            swfstr = "";
                    //            swf_replace(textarea, thisurl, swfstr);
                    //            thisswfstr = swfstr;
                    //            PUHUO.re = cc[i];
                    //            PUHUO.value = textarea;
                    //        }
                    //    } else {
                    //        if (fn.trim(textarea) == "") {
                    //            textarea = tempnr;
                    //            swfstr = "";
                    //            swf_replace(textarea, thisurl, swfstr);
                    //            thisswfstr = swfstr;
                    //            PUHUO.re = cc[i];
                    //            PUHUO.value = textarea;
                    //        }
                }
            }
            if (nn22[1] != undefined && nn22[1].length > 0) {
                PUHUO.nn22re = cc[i];
                PUHUO.nn22re = nn22;
            }
            if (nn11[1] != undefined && nn11[1].length > 0) {
                PUHUO.nn11re = cc[i];
                PUHUO.nn11 = nn11;
            }
            if (nn99[1] != undefined && nn99[1].length > 0) {
                PUHUO.nn99re = cc[i];
                PUHUO.nn99 = nn99;
            }
            a = 1; // cc[i] textarea nn22
        }//end循环
        cc = null;
        d = null;
        a = null;
        ddd = null;
    }

//    if (!empty(nn111) && $this->base64) {
//        nn111 = base64_decode_array(nn111);
//    }
//    if (!empty(nn222) && $this->base64) {
//        nn222 = base64_decode_array(nn222);
//    }
//
    textarea = fn.is_zw(textarea) ? textarea : "";
    thisnn88 = nn88;

    if (thisnn888 == null) {
        if (function_exists('nn888')) {
            nn888 = nn888(nn888, thisurl);
        }
        thisnn888 = (thisnn888 == null || empty(thisnn888)) ? nn888 : thisnn888;
    } else {
        nn888 = null;
    }

    //if (function_exists('nn8888')) {
    //    nn8888 = nn8888(nn8888, thisurl);
    //    if (nn8888 != "") thisnextPage = quanurl(nn8888, thisurl);
    //}

    //if (nn4444[1] != "" && function_exists('nn4444')) {
    //    textarea = "[flash]" . nn4444(nn4444, thisurl, pagehtml) + "[/flash]\r\n\r\n" . textarea;
    //}

    //re2其次使用公共正则
    PUHUO = {re2: "", value: ""};
    if (!fn.is_zw(fn.preg_replace("/<\/?(?!img)[^<>]*>/", "", textarea)) || textarea == "") {
        re2 = "((<img[^<>]+>\s*(<\/?(br|p)[^<>]*>|\s)*){3,})";
        nn00 = new Array();
        nn00[1] = new Array();
        if (fn.preg_match_all("/" + re2 + "/isx", pagehtml, nn00)) {
            endtextarea = nn00[1][0];
            PUHUO.re2 = re2;
            PUHUO.value = nn00[1][0];
        }

        re2 = "<\\!\\-\\-enpcontent\\-\\-><\\!\\-\\-enpcontent\\-\\->(.*)<\\!\\-\\-\\/enpcontent\\-\\->\\s*<\\/td>";
        if (fn.preg_match_all("/" + re2 + "/Uisx", pagehtml, nn00)) {
            textarea = nn00[1][0];
            PUHUO.re2 = re2;
            PUHUO.value = nn00[1][0];
        }

        re2 = "<\\!\\-\\-enpcontent\\-\\->((.*)[\\u4e00-\\u9fa5]{50,}(.*))<\\!\\-\\-\\/enpcontent\\-\\->";
        if (fn.preg_match("/" + re2 + "/Uuisx", pagehtml, nn00)) {
            textarea = nn00[1];
            PUHUO.re2 = re2;
            PUHUO.value = nn00[1];
        }

        re2 = "<div\\s+class=\"clearfix\"\\s+id=\"article_text\">(.*)<div\\s+class=\"page\\-box\">";
        if (fn.preg_match("/" + re2 + "/Uuisx", pagehtml, nn00)) {
            textarea = nn00[1];
            PUHUO.re2 = re2;
            PUHUO.value = nn00[1];
        }

        re2 = "<\\!\-\-function\s+content\(\)\s+parse\s+begin\-\->(.*)<\\!\-\-function\:\s+content\(\)\s+parse\s+end[^<>]*\-\->";
        if (fn.preg_match_all("/" + re2 + "/Uisx", pagehtml, nn00)) {
            textarea = nn00[1][0];
            PUHUO.re2 = re2;
            PUHUO.value = nn00[1][0];
        }
        re2 = "\/enpproperty\-\-><\\!\-\-enpcontent\-\->(.*)<span[^<>]+class\s*=\s*\"pageNum\"[^<>]*>";
        if (fn.preg_match_all("/" + re2 + "/Uisx", pagehtml, nn00)) {
            textarea = nn00[1][0];
            PUHUO.re2 = re2;
            PUHUO.value = nn00[1][0];
        }
        re2 = "<div\\s+id=\"contentarea\">(.*)<\/div>";
        if (fn.preg_match_all("/" + re2 + "/Uisx", pagehtml, nn00)) {
            textarea = nn00[1][0];
            PUHUO.re2 = re2;
            PUHUO.value = nn00[1][0];
        }
        swfstr = "";
        swf_replace(textarea, thisurl, swfstr);
        thisswfstr = swfstr;
    }

    if (textarea == undefined || !fn.is_zw(textarea)) {
        console.log("B8:智能抓取开始！");
        //thistemp = fn.preg_replace("/\\s(target|href|on[a-z]+|span|border)=\"[^<>\"]+\"/Uisx", "", pagehtml);
        //thistemp = fn.preg_replace("/<\/?(link|meta)[^<>]>/Uisx", "", thistemp);
        //thistemp = fn.preg_replace("/border=[0-9]+/isx", "", thistemp);
        var thistemp = pagehtml.replace(/<(script|embed|object|style)[^<>]*>[\s\S]*?<\/\1>/gi,"").replace(/<(?:(\/?)(?!img|br|b|strong))([a-z0-9]+)[^<>]*>/gi,"<$1$2>").replace(/<(?!(\/?)(?:img|b|p|br|strong|td|div))[^<>]*>/gi,"");
        pagehtml="";
        thistemp = fn.preg_replace("/<?!(img|a|b|p|br|font|em|strong|embed|object)\\s*[^<>]*>[^<>]*<\\/\\1>/isx", "", fn.strip_tags(thistemp,"<img><div><td><br><p>"));
        thistemp = fn.preg_replace("/<(script|style)[^<>]*>.*<\/\\1>/Uisx", "", thistemp);
        re=/<div[^<>]*>(?:\s*<div[^<>]*>)?(?:<\/?(?:a|span|p|br|embed|object)[^<>]*>|\s|\&nbsp\;)*(<img[^<>]*>)(?:<\/?(?:a|span|p|br|embed|object)[^<>]*>|(?:[^<>a-z0-9_\s]|\&nbsp\;|\s))*<\/div>(?:\s*<\/div>)?/gi
        thistemp=thistemp.replace(re,"$1");
        nn = new Array();
        nn[3] = new Array();
        gong2=0;
        re=/<div[^<>]*>(?:\s|\t)*((?:<(?:\/?(?:img|br|embed|object|labeal|li|a))[^<>]*>|[^<>])+)\s*?<\/div>/gi;
        while(re.test(thistemp)!=null&&gong2<8) {
            gong2++;
            nnd = new Array();
            fn.preg_match_all("<div[^<>]*>(?:\\s|\\t)*((?:<(?:\\/?(?:img|br|embed|object|labeal|li|a))[^<>]*>|[^<>])+)<\\/div>", thistemp, nnd);
            if(nnd.length>0){
                for (j = 0; j < nnd[0].length; j++) {
                    re2 = new RegExp("(，|。|！|；|、|“|”|～|~)", "gi");
                    re2.lastIndex = 0;
                    mm = nnd[0][j].match(re2);
                    if (mm == null || mm != null && mm.length < 3) {
                        re3=/<img/gi;
                        if(re3.test(nnd[1][j])){
                            thistemp = fn.str_replace(nnd[0][j], nnd[1][j], thistemp);
                        }else{
                            thistemp = fn.str_replace(nnd[0][j], "", thistemp);
                        }
                    }
                }
            }
        }


        thistemp = thistemp.replace(/,/gi, "，").replace(/《/gi, "&gt;&gt;").replace(/》/gi, "&lt;&lt;").replace(/！/gi, "!").replace(/width>/gi, "width&gt;").replace(/width</gi, "width&lt;").replace(/<div>\s*<\/div>/gi,"");
        thistemp = thistemp.replace(/[\r\n]+/gi, "\n").replace(/<(script|style)[^<>]*>.*<\/(script|style)>/gi, "").replace(/<div[^<>]*>(([^a-z\>\<]|\&[a-z]*\;)+)<\/div>/gi, "").replace(/<div>\s*<\/div>/gi,"")
        thistemp = thistemp.replace(/(&nbsp;|<(td|li|div)[^<>]*>\s*(?=<img|<\\2))/gi, " ").replace(/(&nbsp;|<(td|li|div)[^<>]*>\s*(?=<img|<\\2))/gi, " ").replace(/<(?!\/?(img|b|p|em|font|br|div|td|a|embed|object))[^<>]*>/gi, "").replace(/<div>\s*<\/div>/gi,"")
        nn = new Array();
        //fn.preg_match_all("(?:<\\/?(?:img|a|b|p|br|font|em|strong|embed|object)\\s*?[^<>]*?>|(?:[^<>]+?))+?", thistemp, nn);
        fn.preg_match_all("<div[^<>]*>(?:<(?:\\/?(?:img|a|b|p|br|font|em|strong|embed|object))\\s*?[^<>]*?>|[^<>])+<\\/div>", thistemp, nn);
        oldlen = 0;

        maxlen=0;mi=0;
        if(nn!=undefined&&nn[0]!=undefined){
        for (iT = 0; iT < nn[0].length; iT++) {
            nn[0][iT] = fn.trim(nn[0][iT]);
            nn[0][iT] = fn.preg_replace("/\\{[^<>]+\\}/", "", fn.trim(nn[0][iT]));
            if (nn[0][iT] == "") continue;
            jf = 0;
            jj = new Array();
            jj[0] = new Array();
            fn.preg_match_all("/(width=['\"]?([5-9][0-9]{2,})|max\\-width\:\s*([5-9][0-9]{2,})px\;|ԭͼ|bigimg|onclick|onerror|javascript|uploads?)/i", nn[0][iT], jj);
            for (j = 0; j < jj[0].length; j++) {
                jf += 300;
            }
            jj = new Array();
            jj[0] = new Array();
            fn.preg_match_all("/((?:width|height)=['\"]?([1-2][0-9]{1,2})|max\\-(?:width|height)\\:\\s*([1-2][0-9]{1,2})px\\;)/i", nn[0][iT], jj);
            for (j = 0; j < jj[0].length; j++) {
                jf = jf - fn.strlen(nn[0][iT]) - 300;
            }
            jj = new Array();
            jj[0] = new Array();
            fn.preg_match_all("/(，|。|！|；|、|“|”)/isx", fn.preg_replace("/<[^<>]*>/", "", fn.stripa(nn[0][iT])), jj);
            if (!fn.preg_match("/版权|所有|备案|未经/Uisx", nn[0][iT])) jf += 100 * jj[0].length;

            jj = new Array();
            jj[0] = new Array();
            fn.preg_match_all("/<\/?p[^<>]*(text\\-align\\:center|align=\"center\")[^<>]*>([^<>]|<(a|span|br)[^<>]*>)*<img[^<>]*>/isx", nn[0][iT], jj);
            for (j = 0; j < jj[0].length; j++) {
                jf += 100;
            }
            jj = new Array();
            jj[0] = new Array();
            fn.preg_match_all("/<img[^<>]*(，|。|；|、|～|~|uploads|\\(|\\[?)[^<>]*>/isx", nn[0][iT], jj);
            for (j = 0; j < jj[0].length; j++) {
                jf += 300;
            }

            nn1 = new Array();
            nn1[0] = new Array();
            fn.preg_match("/<img[^<>]*>([^<>]*)(<div|<img|u|br|p)/Uuisx", nn[0][iT], nn1);
            jj = new Array();
            jj[0] = new Array();
            fn.preg_match_all("/<(p|br)[^<>]*>\\s*[\\u4e00-\\u9fa5]/u", fn.stripa(nn1[1]), jj);
            for (j = 0; j < jj[0].length; j++) {
                if (j < 3) {
                    jf += 200;
                } else {
                    jf += 500;
                }
            }

            strlen_jifen_count = strlen_jifen(nn[0][iT]);
            if (strlen_jifen_count + jf > oldlen) {
                oldlen = strlen_jifen_count + jf;
                mi = iT;
                //nn[0][iT]="==".oldlen."==".nn[0][iT];
                maxlen = oldlen;
            }
        }}
        if (fn.maxlen(textarea) < maxlen){
            textarea = nn[0][mi];
        }
        swfstr = "";
        swf_replace(textarea, thisurl, swfstr);
        thisswfstr = swfstr;
        if(mi!=0) {
            if (strlen_jifen(nn[0][mi - 1]) > 400 && fn.hasimg(nn[0][mi - 1])) textarea = nn[0][mi - 1] + "\r\n" + textarea;
            if (strlen_jifen(nn[0][mi + 1]) > 400 && fn.hasimg(nn[0][mi + 1])) textarea = textarea + "\r\n" + nn[0][mi + 1];
        }
    }
//
//
//    //后阶段处理之EXEC
//    if (nn22[1].length > 0 && !fn.is_zw(fn.preg_replace("/<\/?(?!img|embed|object)[^<>]*>/Uisx", "", textarea))) {
//        textarea = "";
//    }
////        fn.preg_match_all("/<table[^<>]*>((?<!<\/table>).(?!<table))*<\/table>/Uisx",textarea,$ttbbnn);
////        for($i=0;$i<$ttbbnn[0].length;$i++){
////            $TTBB[$i]=$ttbbnn[0][$i];
////            textarea=fn.str_replace($ttbbnn[0][$i],"TTBB[".$i."]",textarea);
////        }
//
//
    textarea = delete_Public(textarea,rs);
    params = {"nn22":nn22, "nn44" : nn44, "nn55" : nn55, "nn66" : nn66, "nn11" : nn11, "nn99": nn99, "nn111" : nn111, "nn222" : nn222};
    thissecexe=(thissecexe==undefined)?0:thissecexe;
    textarea = evalpublic(textarea, thisurl, params, rs, thisbaseurl, thissecexe);
//    if (nn66[1].length > 0) {
//        $this->nn66 = clnn66(nn66);
//    }
//    textarea = (textarea == "") ? $endtextarea : textarea;
//    $C = $this->C;
//    if ($rs['exec'] != "" && !$this->secexe) {
//        oldurl = thisurl;
//        $fn = fopen("includetemp.php", "w");
//        fwrite($fn, "<" . "?php\r\n" . $rs['exec'] . "\r\n?" . ">");
//        fclose($fn);
//        include("includetemp.php");
//        $this->secexe = 0;
//        $this->title = (fn.trim($GLOBALS[title]) != "") ? $GLOBALS[title] : $this->title;
//    }
//    textarea = changeloadimg(textarea, $this->rs, thisurl);
    textarea = fn.preg_replace("(\\[align=center\\]\\s*?\\[\\/align\\](\\s|　)*){2,}", "\r\n　　", textarea);
    textarea = fn.preg_replace("\\[media[^<>\\[\\]]*\\][^<>\\[\\]]*Array\\[\\/media\\]", "", textarea);
    textarea = fn.preg_replace("\\s*?(\\[hr\\](\\s|　|\\n|\\r|\\t)*?)+?", "\r\n[hr]", textarea);
    textarea = fn.preg_replace("\\[img\\]", "\n[img]", textarea);
    textarea = fn.preg_replace("<(?!img)[^<>]*>", "", textarea);
    textarea = fn.preg_replace("\\&nbsp\\;", "　", textarea);
//    //textarea=$this->getflv().textarea;
//
//    //Delete
    if (rs.delete != null) {
        dd = fn.preg_split("/\\|\\|\\||[\\r\\n]+|$/m", rs.delete);
        for (i8 = 0; i8 < dd.length; i8++) {
            if (fn.trim(dd[i8]) == "") continue;
            mm = fn.preg_split("/@@/", dd[i8]);
            if (fn.preg_match("/\:y(?=\:|$)/Uisx", fn.trim(mm[0]))) {
                mm[0] = fn.preg_replace("/\:y(?=\:|$)/", "", fn.trim(mm[0]));
            } else if (fn.preg_match("/\:g(?=\:|$)/Uisx", fn.trim(mm[0]))) {
                mm[0] = fn.preg_replace("/\:g(?=\:|$)/Uisx", "", fn.trim(mm[0]));
            }
            textarea_old = textarea;
            textarea = fn.preg_replace("/" + fn.trim(mm[0]) + "/Uisx", fn.trim(mm[1]), textarea);
            change = (fn.trim(textarea_old) == fn.trim(textarea)) ? false : true;
            a = 1; //测试是哪条规则删除了内容 fn.trim(mm[0])和change
        }
    }
    //textarea = fn.preg_replace("/TTBB\[([0-9]+)\]/Usxe", 'ttbb("\\1",$TTBB)', textarea);
    textarea = fn.preg_replace("/\\[table[^<>\\[\\]]*\\].*(下一页|下页|上一页|上页).*\\[\\/table\\]/Uisx", "", textarea);
//    if ($this->gather_type == 5) {
//        $GLOBALS['nn55'][0]['文章'] = textarea;
//        $GLOBALS['nn55'][0]['标题'] = $this->title;
//        return json_encode($GLOBALS['nn55']);
//    }
//    if ($this->gather_type == 4) {
//        $GLOBALS['nn55'][0]['文章'] = textarea;
//        $GLOBALS['nn55'][0]['标题'] = $this->title;
//        return print_r($GLOBALS['nn55'], 1);
//    }
//    if ($this->gather_type == 2) {
//        fn.preg_match_all("/(http\:\/\/[^<>\[\]]*(?:jpg|png|gif|jpeg))/i", textarea, nn);
//        $str = "";
//        for (i = 0; $i < nn[1].length; $i++) {
//            str .= nn[1][i] + "\r\n";
//        }
//        return $str;
//    }
//
//    if ($this->gather_type == 3) {
//        fn.preg_match_all("/(http\:\/\/[^<>\[\]]*\.(?:swf|flv|mp[0-9]+|rm|rem|mov|avi|mpg|mpeg))/i", textarea, nn);
//        $str = "";
//        for ($i = 0; $i < nn[1].length; $i++) {
//            $str .= nn[1][i] . "\r\n";
//        }
//        return $str;
//    }

    comeback(textarea);
}


function getfenye(pagehtml, comeback) {
    nextpage = "";
    if (thisnn88 != "" && thisnn88.length > 0) {
        nextpage = getNextPage(thisnn88, pagehtml);
        returnurl=nextpage;
    }

    if(nextpage==""){
        nextpagerem = thisnextpagerem;
        nextpagerez = (thisnextpagere) ? "|"+fn.trim(thisnextpagere) : "";

        re = "<a[^<>]*href=(?:[\\'\"\\s]*)??(?!\\#)([^<>\"\\'\\s]+?)[^<>]*>(?:<\\/?(?:br|span|strong|b|font)[^<>]*>|\\s|\\[)*(下一页|下一页|下一頁|下页|后一页|下一张|后页|Next|(?:(?:\\&gt\\;)+)(?=\\<|\\s)|>>" + nextpagerez + ")";
        mm = new Array();
        fn.preg_match_all(re, pagehtml, mm);
        if (mm.length < 1 || mm[1].length < 1) {
            re = "(?:href|location)=(?:[\\'\"\\s]*)??(?!\\#)([^<>\"\\']+?)[^<>]*(?:alt|title|class)\s*=[\\'\"\\s]?(下一页|下一页|下一頁|下页|后一页|下一张|后页|Next|pageNext)";
            fn.preg_match_all(re, pagehtml, mm);
        }
        if (mm.length < 1 || mm[1].length < 1) {
            re = "(?:alt|title|class)=[\\'\"\s]??(?!\\#)(?:下一页|下一頁|下一页|下页|后一页|下一张|后页|Next|pageNext)[\\'\"\\s]?[^<>]*(?:href|location)\s*=[\\'\"\\s]??([^<>\\'\"]+?)";
            fn.preg_match_all(re, pagehtml, mm);
        }
        returnurl = (mm.length < 1) ? "" : fn.quanurl(fn.trim(mm[1][0]), exports.url, exports.baseurl);
        pagehtml = null;
        nextpagerez = null;
        nextpagerem = null;
    }
    re23=/javascript\:|script/gi;
    if(re23.test(returnurl)){
        returnurl="";
    }
    comeback(returnurl);
}

function getNextPage(rearr, nr)
{
    if (fn.is_array(rearr) &&rearr.length > 0) {
        for (pp = 0; pp < rearr.length; pp++) {
            mm=new Array();
            if (fn.preg_match("/" +rearr[pp] + "/Uisx", nr, mm)) {
                //if (function_exists('nn88')) {
                //    mm[1] = nn88(mm[1]);
                //}
                mm[1] = fn.str_replace('&amp;', '&', mm[1]);
                return fn.quanurl(mm[1],thisurl,thisbaseurl);
                break;
            }
        }
    }
    return "";

}

function gaiSrc(str, src) {
    str = fn.preg_replace("src=([\"\\'])??([^\\s\"\\']+?)(?=\\\\1|\\s|\"|\\'>)", "src=\\1".fn.trim(src), str);
    return $str;
}

function delete_Public(textarea,rs){
    textarea = droppagetablediv(textarea, thisnextpagere);
    textarea = deletePublic(textarea, thisurl, rs.clhc,thisbaseurl,0);
    return textarea;
}

function droppagetablediv(nr, nextpagere)
{
    if(nr==""||nr==null||nr==undefined) return "";
    re = "[\s\S]*(下一页|下页|上一页|上页" +nextpagere +")[\s\S]*";//(?<![^\\<\\>a-z0-9_\\s])
    nr = nr.replace(/<(p|div|td)[^<>]*>[\s\S]*(下一页|下页|上一页|上页)[\s\S]*<\/\1>/gi, "");
    nr = nr.replace(/(<p[^<>]*>|下一页|下页|上一页|上页|第|页|[0-9]|\]|\[|&nbsp;|<br\/?>)*(<\/p>|$|\r|\n)/gi, "");
    nr = fn.preg_replace("/<table[^<>]*>"+re+"<\\/table>/Uisx", "", nr);
    nr = fn.preg_replace("/&lt;table[^<>]*&gt;"+re+"}&lt;\\/table&gt;/Uisx", "", nr);
    nr = fn.preg_replace("/<div[^<>]*>"+re+"<\/div>/Uisx", "", nr);
    nr = fn.preg_replace("/&lt;div[^<>]*&gt;"+re+"&lt;\\/div&gt;/Uisx", "", nr);
    nr = fn.preg_replace("/(\\[?上一页|下一页|\\[[0-9]+\\](?:\\[|\\s\\<))[\s\S]*$/Uisx", "", nr);
    nr = fn.preg_replace("/前一页|首页/Uisx", "", nr);
    return nr;
}

function deletePublic(textarea, thisurl, clhc, thisbaseurl, lie_a) {
    thisbaseurl = (thisbaseurl == "" || thisbaseurl == undefined) ? "" : thisbaseurl;
    lie_a = (lie_a == "" || lie_a == undefined) ? "" : lie_a;

    //fn.preg_match_all("<img(?:(?<=Width)>|[^<>])*?window\\.open\\('(http[^<>]*\.(?:jpg|gif|png|jpeg))(?:(?<=Width)>|[^<>])*?>",textarea,nn);
    //for(i=0;i<count(nn[1]);i++){
    //    textarea=fn.str_replace(nn[0][i],gaiSrc(nn[0][i],nn[1][i]),textarea);
    //}

    if (fn.is_string(textarea)) {
        textarea = fn.strip_jscss(textarea, lie_a); //####
        textarea = fn.preg_replace("(<img[^<>]*)\\s+?\\/>", "\\1>", textarea);
        textarea = fn.preg_replace("<span[^<>]*style=\\\\\\?\"display\\:none\\\\\\?\"[^<>]*>.*<\\/span>", "", fn.trim(textarea));
        textarea = fn.preg_replace("<span[^<>]*>|<\\/\\s*span>", "", textarea);
        textarea = fn.preg_replace("\\(微博\\)", "", fn.trim(textarea));
        textarea = fn.preg_replace("([0-9]+\\-[0-9]+\\-[0-9]+\\s[0-9]+\\:[0-9]+\\:[0-9]+\\s上传|下载附件).*[\r\n]", "", textarea);
        textarea = fn.preg_replace("<(\\/?)(b|strong)\\s*\\/?>", "[\\1b]", textarea);
        textarea = fn.preg_replace("thumb_[0-9]+_[0-9]+_", "", textarea);
        textarea = fn.preg_replace("^.*\\/enpproperty\\-\\-\\>", "", fn.trim(textarea));
        textarea = fn.preg_replace("([0-9\\-]+\\s+[0-9\\:]+|[0-9]天前)\\s*(上传|修改|发表|更新)", "", fn.trim(textarea));
        textarea = fn.preg_replace("<fieldset[^<>]*>(.*)<\\/fieldset>", "", fn.trim(textarea));
        textarea = fn.str_replace('src="static/image/common/none.gif" ', '', textarea);
        textarea = fn.str_replace('zoomfile', 'src', textarea);
        textarea = fn.preg_replace("<\\/?br\\s*\\/?>|&lt;\\/br\s*\\/?&gt;", "\r\n", textarea);
        textarea = fn.htmltotxt(textarea, clhc, thisurl, exports.baseurl, lie_a,rs);
        textarea = fn.preg_replace("\\[img\\][^<>\\[\\]]*(\\/images?\\/smiley\|images?\\/common\\/|\\/images?\\/smilies\\/|\\/miba\\/images\\/|images\\/attachicons\\/|\\/common\\/cf\\/)[^<>\\[\\]]*\\[\\/img\\]|\\[b\\]下载\\[\\/b\\]|\\([0-9\\.a-z\\s]+KB\\)|[0-9]+天前[0-9\\:]+?|附件\\:\\s*您所在的用户组无法下载或查看附件|<\\/?blockquote[^<>]*>", "", textarea);
        textarea = fn.preg_replace("\\([\\s0-9\\.]+KB\\,?\\s*(下载次数\\:\\s*[\\s0-9]+)?\\)|下载次数\:[\\s0-9]+?|(\\s|　)[^\\s]+\\.jpg(\\s|　)", "\r\n", textarea);
        textarea = fn.preg_replace("本帖.*[0-9\\-\\s\\:]编辑|<\\/img>|<br\\s*\\/>|\\&lt\\;br\\s*\\/\\&gt\\;", "", textarea);
        textarea = fn.preg_replace("本主题由[^\\r\\n]*?", "", textarea);
        textarea = fn.preg_replace("保存到相册|点击文件名|马上注册，.*？注册|\\[img\\][^<>\\[\\]]*qq_login.gif\\[\\/img\\]", "", textarea);
        textarea = fn.preg_replace("　　回复.*$", "", textarea);
        textarea = fn.preg_replace("(\\r(　|\\s)*?\\n)+?|[\\r\\n](　|\\s)*?[\\r\\n]+?", "\n", textarea);
        textarea = fn.preg_replace("[\\r\\n]+?　　(\\[hr\\]\\s*?)+?", "[hr]", textarea);
        textarea = fn.preg_replace("(\\[hr\\](\\s|　)*?)+?", "[hr]", textarea);
    } else if (fn.is_array(textarea)) {
        for (t = 0; t < textarea.length; t++) {
            textarea[t] = deletePublic(textarea[t], thisurl, clhc);
        }
    }
    return textarea;
}


function swf_replace(nr, thisurl, swfstr, host) {
    nnswf = arr = new Array();
    nnswf[0] = new Array();
    nnswf[1] = new Array();
    width = 0;
    height = 0;

    nr = fn.preg_replace("/<div\\s+class=\"cornerlayger\">(.*)<\\/div>/Uisx", "", fn.trim(nr));
    nr = fn.preg_replace("/<p\\s+class=\"imgtitle\">(.*)<\\/p>/Uisx", "", nr);
    nr = fn.preg_replace("/<div\\s+class=\"cornerlayger\">(.*)<\\/div>/Uisx", "", nr);
    nr = fn.preg_replace("/点击图片进入下一页|点击图片进下页/Uisx", "", nr);
    if (host == "sina.com.cn") {
        if (fn.preg_match_all("/<\\!\\-\\-\\s*flash\\s+player\\s+begin\\s+\\-\\->.*<\\!\\-\\-\\s+flash\\s+player\\s+end\\s+\\-\\-\\>/Uisx", nr, nnswf)) {
            swfstr = nnswf[0][0];
            return nr;
        }

        if (fn.preg_match_all("/<div[^<>]*id=\"artibody\"[^<>]*>.*<\\!\\-\\-\\spublish_helper_end\\s\\-\\->.*<\/div>/Uisx", nr, nnswf)) {
            swfstr = nnswf[0][0];
            return nr;
        }

        temp = swfhost(nr, thisurl, swfstr, "sina.com.cn");
        if (temp != "") swfstr += "[flv,500,400]" + temp + "[/flv]\r\n";
    }


//echo swfstr;exit;
    nnswf=new Array();nnswf[1]=new Array();
    fn.preg_match_all("/(<object[^<>]*>(.*<\/object>)?)/Uisx", nr, nnswf);
    for (iW = 0; iW < nnswf[1].length; iW++) {
        if (fn.preg_match("/\\/ad\\//i", nnswf[1][iW])) continue;
        if (fn.preg_match("/name=\"filename\"\\s+value=\"([^<>]*\\.(swf|flv|rm|rmvb|mov|avi|wmv|hlv)[^<>]*)\"/Uisx", nnswf[1][iW], ss)) {
            mm = ss;
        }

        if (mm == "" && fn.preg_match("/value=\"[^<>\\s\"']*(http:\\/\\/[^<>\\s\"']*\.(flv|rm|rmvb|mov|avi|wmv|hlv))[^<>]*\"/Uisx", nnswf[1][iW], ss)) {
            mm = ss;
        }

        if (mm == "" && fn.preg_match("/value=\"[^<>\\s\"']*(http:\/\/[^<>\\s\"']*\.(swf))[^<>]*\"/Uisx", nnswf[1][iW], ss)) {
            mm = ss;
        }

        if (fn.in_array(mm[1], arr)) continue;
        arr.push(mm[1]);
        fn.preg_match("/WIDTH\\:\\s*([0-9]+)px/Uisx", nnswf[1][iW], mm2);
        width = mm2[1];
        fn.preg_match("/height\\:\\s*([0-9]+)px/Uisx", nnswf[1][iW], mm2);
        height = mm2[1];
        if (width == "") {
            fn.preg_match("/width=\"([0-9]+)\"/Uisx", nnswf[1][iW], mm2);
            width = mm2[1];
        }
        if (height == "") {
            fn.preg_match("/height=\"([0-9]+)\"/Uisx", nnswf[1][iW], mm2);
            height = mm2[1];
        }
        if (fn.preg_match("/flashvars=\"(.*)\"/Uisx", nnswf[1][iW], mm3)) {
            $vars = (fn.preg_match("/\\?/", mm[1]) ? "&" : "?").mm3[1];
        }
        if (!fn.preg_match("/flv|swf|avi|rm|mp[0-9]|mov|wmv/i", mm[1]) || (!fn.preg_match("/\\=/i", mm[1]+vars) && !fn.preg_match("/[0-9]{3,}(?\.\/)/i", mm[1]+vars)) || fn.preg_match("/\'|\"/i", mm[1].$vars)) continue;
        flvurl = fn.quanurl(mm[1], thisurl)+vars;
        if (width < 1000 && height > 300 && fn.trim(flvurl) != "") {
            if (fn.preg_match("/swf|flv/Uisx", "mm[2]")) {
                swfstr += "[flash={width},{height}]" + flvurl + "[/flash]\r\n";
            } else if (fn.preg_match("/avi|mpg|mpeg|rm|wmv|mov|mp[0-9]+/Uisx", "mm[2]")) {
                swfstr += "[media={width},{height}]" + flvurl + "[/media]\r\n";
            }
        }

    }

    mm = new Array();
    mm[1] = new Array();
    mm2 = new Array();
    mm2[1] = new Array();
    if (fn.preg_match_all("/vid=([^<>]*)(\&|\"|$|\>)/isx", nr, mm)) {
        vid = mm[1][0];
        if (width == "") {
            fn.preg_match("/width=\"([0-9]+)\"/Uisx", nnswf[1][iW], mm2);
            width = mm2[1];
        }
        if (height == "") {
            fn.preg_match("/height=\"([0-9]+)\"/Uisx", nnswf[1][iW], mm2);
            height = mm2[1];
        }

        if (host == "ku6.com") {
            mm[1] = "http://player.ku6.com/refer/{vid}/v.swf";
            mm[2] = "http://player.ku6.com/refer/{vid}/v.swf";
        }

        arr.push(mm[1]);
        //echo nnswf[2];exit;
        if (width <= 1000 && height > 200 && fn.trim(mm[2]) != "") {
            if (fn.preg_match("/swf|flv/Uisx", "mm[2]", mmz)) {
                swfstr += "[flash={width},{height}]" + fn.quanurl(mm[1], thisurl) + "[/flash]\r\n";
            } else if (fn.preg_match("/avi|mpg|mpeg|rm|wmv|mov|mp[0-9]+/Uisx", "mm[2]")) {
                swfstr += "[media={width},{height}]" + fn.quanurl(mm[1], thisurl) + "[/media]\r\n";
            }
        }
    }

    fn.preg_match_all("/(<embed[^<>]*>(.*<\/embed>)?)/Uisx", nr, nnswf);
    for (iW = 0; iW < nnswf[1].length; iW++) {
        if (fn.preg_match("/\\/ad\\//i", nnswf[1][iW]) || fn.trim(nnswf[1][iW]) == "") continue;
        if (fn.preg_match("/(?:file|src)=([^<>]*\\.(swf|flv|rm|rmvb|mov|avi|wmv|hlv|mp[0-9]+)[^<>]*)\"/Uisx", nnswf[1][iW], mm)) {
            mm[1] = fn.urldecode(fn.preg_replace("/\"/", "", mm[1]));
            mm[1] = fn.preg_replace("/autostart=false/", "autostart=true", mm[1]);
            mm[1] = fn.preg_replace("/&amp;/", "&", mm[1]);
            if (fn.in_array(mm[1], arr)) continue;
            arr.push(mm[1]);
            fn.preg_match("/WIDTH=\"?\\s*([0-9]+)/isx", nnswf[1][iW], mm2);
            width = mm2[1];
            fn.preg_match("/height=\"?\\s*([0-9]+)/isx", nnswf[1][iW], mm2);
            height = mm2[1];
            mm3 = new Array();
            vars = "";
            if (fn.preg_match("/flashvars=\"(.*)\"/Uisx", nnswf[1][iW], mm3)) {
                vars = (fn.preg_match("/\\?/", mm[1]) ? "&" : "?") + mm3[1];
            }
            if (!fn.preg_match("/flv|swf|avi|rm|mp[0-9]|mov|wmv/i", mm[1]) || fn.preg_match("/'|\"/i", mm[1] + vars)) continue;
            if (fn.preg_match("/swf|flv/Uisx", "mm[2]")) {
                swfstr += "[flash={width},{height}]" + fn.quanurl(mm[1], thisurl) + vars + "[/flash]\r\n";
            } else if (fn.preg_match("/avi|mpg|mpeg|rm|wmv|mov|mp[0-9]+/Uisx", "mm[2]")) {
                swfstr += "[media={width},{height}]" + fn.quanurl(mm[1], thisurl) + vars + "[/media]\r\n";
            }
        }

    }

    fn.preg_match_all("/\&lt\;object.*param\s+name=\&quot\;movie\&quot\;\s+value=\&quot\;([^<>]+)\&quot\;/Uisx", nr, nnswf);
    for (iW = 0; iW < nnswf[1].length; iW++) {
        if (fn.preg_match("/\\/ad\\//i", nnswf[1][iW])) continue;
        fn.preg_match("/WIDTH=(?:\"|\\&quot\\;)?\s*([0-9]+)/isx", nnswf[iW][0], mm2);
        width = mm2[1];
        fn.preg_match("/height=(?:\"|\\&quot\\;)?\s*([0-9]+)/isx", nnswf[iW][0], mm2);
        height = mm2[1];
        if (!fn.preg_match("/flv|swf|avi|rm|mp[0-9]|mov|wmv/i", nnswf[1][iW]) || (!fn.preg_match("/\\=/i", nnswf[1][iW] + vars) && !fn.preg_match("/[0-9]{3,}(?\.\/)/i", nnswf[1][iW] + vars)) || fn.preg_match("/\'|\"/i", nnswf[1][iW].$vars)) continue;
        if (width <= 1000 && height > 200) {
            if (fn.preg_match("/swf|flv/Uisx", "nnswf[1][iW]", oo)) {
                swfstr += "[flash={width},{height}]" + fn.quanurl(nnswf[1][iW], thisurl) + "[/flash]\r\n";
            } else if (fn.preg_match("/avi|mpg|mpeg|rm|wmv|mov|mp[0-9]+/Uisx", "mm[2]")) {
                swfstr += "[media={width},{height}]" + fn.quanurl(nnswf[1][iW], thisurl) + "[/media]\r\n";
            }
        }
    }

    fn.preg_match_all("/\\,videoSrc\\:\\s+'(.*)'/Uisx", nr, nnswf);
    for (iW = 0; iW < nnswf[1].length; iW++) {
        fn.preg_match("/WIDTH=(?:\"|\\&quot\\;)?\s*([0-9]+)/isx", nnswf[iW][0], mm2);
        width = mm2[1];
        fn.preg_match("/height=(?:\"|\\&quot\\;)?\s*([0-9]+)/isx", nnswf[iW][0], mm2);
        height = mm2[1];
        oo = new Array();
        if (fn.preg_match("/swf|flv/Uisx", "nnswf[1][iW]", oo)) {
            swfstr += "[flash=580,280]" + fn.quanurl(nnswf[1][iW], thisurl) + "[/flash]\r\n";
        } else if (fn.preg_match("/avi|mpg|mpeg|rm|wmv|mov|mp[0-9]+/Uisx", "mm[2]")) {
            swfstr += "[media=580,280]" + fn.quanurl(nnswf[1][iW], thisurl) + "[/media]\r\n";
        }
    }

    fn.preg_match_all("/var\\s*ad\\s*=\\s*'([^<>]*)';\\s*var\\s*w\\s*=\\s*'([0-9]*)';\\s*var\\s*h\\s*=\\s*'([0-9]*)';/Uisx", nr, nnswf);
    for (iW = 0; iW < nnswf[1].length; iW++) {
        if (fn.preg_match("/swf|flv/Uisx", "nnswf[1][iW]", oo)) {
            swfstr += "[flash={nnswf[2][iW]},{nnswf[3][iW]}]" + fn.quanurl(nnswf[1][iW], thisurl) + "[/flash]\r\n";
        } else if (fn.preg_match("/avi|mpg|mpeg|rm|wmv|mov|mp[0-9]+/Uisx", "mm[2]")) {
            swfstr += "[media={nnswf[2][iW]},{nnswf[3][iW]}]" + fn.quanurl(nnswf[1][iW], thisurl) + "[/media]\r\n";
        }
    }

    ss = new Array();
    fn.preg_match_all("/<script[^<>]*>(.*)<\/script>/Uisx", nr, nnswf);
    for (iW = 0; iW < nnswf[1].length; iW++) {
        if (fn.preg_match("/\\/ad\\//i", nnswf[1][iW])) continue;
        if (fn.preg_match("/\"file\"\\s*\\,\\s*\"([^<>]*\\.(swf|flv|rm|rmvb|mov|avi|wmv|hlv))\"/Uisx", nnswf[1][iW], ss)) {
            mm = ss;
        }
        if (fn.preg_match("/file\\s*\\:\\s*\"([^<>]*\\.(swf|flv|rm|rmvb|mov|avi|wmv|hlv))\"/Uisx", nnswf[1][iW], ss)) {
            mm = ss;
        }
        if (fn.preg_match("/data\\s*=\\s*([^<>]*\\.(swf|flv|rm|rmvb|mov|avi|wmv|hlv))/Uisx", nnswf[1][iW], ss)) {
            mm = ss;
        }
        if (fn.preg_match("/'src'\\s*\\,\\s*'([^<>]*)'/Uisx", "nnswf[1][iW]", ss)) {
            mm = ss;
            flash = 1;
        }

        if (fn.in_array(mm[1], arr)) continue;
        arr.push(mm[1]);
        if (fn.preg_match("/width\"?\s*(?:,|\\:|\\=)\s*\"?\s*([0-9]+)/isx", nnswf[1][iW], mm2)) width = mm2[1];
        if (fn.preg_match("/height\"?\s*(?:,|\\:|\\=)\s*\"?\\s*([0-9]+)/isx", nnswf[1][iW], mm2)) height = mm2[1];
        if (fn.preg_match("/width=\"([0-9]+)\"/Uisx", nnswf[1][iW], mm2)) width = mm2[1];
        if (fn.preg_match("/height=\"([0-9]+)\"/Uisx", nnswf[1][iW], mm2)) height = mm2[1];
        if (fn.preg_match("/'width'\\,'([0-9]+)'\\,'height'\\,'([0-9]+)'/Uisx", nnswf[1][iW], mm2)) {
            width = mm2[1];
            height = mm2[2];
        }
        if (fn.preg_match("/'width'\\,'([0-9]+)'\\,'height'\\,'([0-9]+)'/Uisx", nnswf[1][iW], mm2)) {
            width = mm2[1];
            height = mm2[2];
        }


        flvurl = fn.quanurl(mm[1], thisurl);
        if (width <= 1000 && height > 200 && flvurl != "" && !fn.preg_match("/\"/", $flvurl)) {
            if (fn.preg_match("/swf|flv/Uisx", "mm[2]") || $flash) {
                swfstr += "[flash={width},{height}]" + $flvurl + "[/flash]\r\n";
            } else if (fn.preg_match("/avi|mpg|mpeg|rm|wmv|mov|mp[0-9]+/Uisx", "mm[2]")) {
                swfstr += "[media={width},{height}]" + flvurl + "[/media]\r\n";
            }
        }
    }

    vv = new Array();
    if (vid == "" && fn.preg_match("/\\/v\\/[0-9]\\/[a-z]\\/([^<>]+)\\.html/Uisx", thisurl, vv)) {
        vid = vv[1];
        if (host == "qq.com") {
            nnswf[1][0] = "http://static.video.qq.com/TPout.swf?vid={vid}&auto=1";
            if (fn.preg_match("/swf|flv/Uisx", nnswf[1][iW], oo)) {
                swfstr += "[flash=580,280]" + fn.quanurl(nnswf[1][0], thisurl) + "[/flash]\r\n";
            } else if (fn.preg_match("/avi|mpg|mpeg|rm|wmv|mov|mp[0-9]+/Uisx", "mm[2]")) {
                swfstr += "[media=580,280]"+fn.quanurl(nnswf[1][0], thisurl) + "[/media]\r\n";
            }
        }
    }
    if (vid == "" && fn.preg_match("/\\?vid=([^\\&<>]+)/isx", thisurl, vv)) {
        vid = vv[1];
        if (host == "qq.com") {
            nnswf[1][0] = "http://static.video.qq.com/TPout.swf?vid={vid}&auto=1";
            if (fn.preg_match("/swf|flv/Uisx", nnswf[1][iW], oo)) {
                swfstr += "[flash=580,280]"+fn.quanurl(nnswf[1][0], thisurl) + "[/flash]\r\n";
            } else if (fn.preg_match("/avi|mpg|mpeg|rm|wmv|mov|mp[0-9]+/Uisx", "mm[2]")) {
                swfstr += "[media=580,280]"+fn.quanurl(nnswf[1][0], thisurl) + "[/media]\r\n";
            }
        }
    }
    swfstr = fn.preg_replace("/vid\\=\\&/Uisx", "vid={vid}&", swfstr);
    swfstr = fn.preg_replace("/vid='\\s*vid\\s*'/Uisx", "vid={vid}", swfstr);

    return nr;
}

function strlen_jifen(str) {
    str = fn.preg_replace("/<a\\s?[^<>]*>.*<\\/a>/Uisx", "", str);
    str = fn.preg_replace("/<[^<>]*>/Uisx", "", str);
    str = fn.preg_replace("/\\s+/isx", " ", str);
    return fn.strlen(str);
}


function evalpublic(textarea, thisurl, params, rs, thisbaseurl,thissecexe,lie_a)
{
    var returntextarea=textarea;
    lie_a=(lie_a==undefined||lie_a=="")?false:lie_a;
    //global $nn55;
    var href="";
    var title="";
    var url="";
    var nn221=new Array();
    var nn44=new Array();
    var nn11=new Array();
    var nn22=new Array();
    var nn44=new Array();
    var nn55=new Array();
    var nn66=new Array();
    var nn111=new Array();
    var nn222=new Array();
    var nn99=new Array();
    var nn222=new Array();
    nn221[1]=new Array();

    for (name in params) {
        eval(name+"=params."+name+";");
        //if (is_array(v)) {
            //if (function_exists($k)) {
            //    v = call_user_func($k, $v);
            //}
    //    }
    }

    if (nn221[1].length > 0) {
        nn22 = nn221;
    }
    if (nn22.length>0&&nn22[1].length > 0) {
        tempstr = "";
        for (k = 0; k < nn22[1].length; k++) {
            v=nn22[k];
            nn22[1][k] = fn.utf8encode(nn22[1][k]);
            if(nn22[2]!=undefined) nn22[2][k] = fn.utf8encode(nn22[2][k]);
            if(nn22['url']!=undefined&&(nn22['url'][k]!=""||nn22['title'][k]!="")){
                url = nn22['url'][k];
                href = nn22['href'][k];
                title = nn22['title'][k];
                if(!fn.preg_match("/^[0-9]+$/",nn22[jj][k])){
                    title+=nn22[jj][k];
                }
            }else{
                nn=new Array();
                var url="";
                var title="";
                if (fn.preg_match("/(^http[^<>\\s]*(?:jpg|jpeg|gif|png|bmp)|\\.[a-zA-Z0-9]+(?:jpg|jpeg|gif|png|bmp)$)/Uisx", nn22[1][k], nn)) {
                    url = nn22[1][k];
                    if(nn22[2]!=undefined) title = nn22[2][k];
                } else {
                    if(nn22[2]!=undefined)  url = nn22[2][k];
                    title = nn22[1][k];
                }
            }
            url = fn.str_replace('\/', "/", fn.trim(url));
            url = fn.preg_replace("/_small\\.jpg/Uisx", ".jpg", fn.trim(url));
            url = fn.preg_replace("/thumb_[0-9]+_[0-9]+_/Uisx", "", fn.trim(url));
            if(href!=undefined&&href!=""){
                tempstr += "<a href=\""+href+"\">"+fn.trim(createimgubb(url, title, rs.loadimg, thisurl, thisbaseurl))+"</a>";
            }else{
                tempstr+= createimgubb(url, title, rs.loadimg, thisurl, thisbaseurl);
            }

        }
        tempstr = deletePublic(tempstr, thisurl, 0,thisbaseurl,lie_a);
        var returntextarea = (fn.maxlen(tempstr) > fn.maxlen(textarea)) ? tempstr : textarea+tempstr;
        a = 1;
    }

    if (nn44.length>0&&nn44[1].length > 0) {
        var returntextarea="";
        tempstr = "";
        for (k = 0; k < nn44[1].length; k++) {
            nn44[1][k] = fn.utf8encode(nn44[1][k]);
            title="";
            if(nn44.length>2) nn44[2][k] = fn.utf8encode(nn44[2][k]);
            nn=new Array();
            if (fn.preg_match("/(^http[^<>\\s]*|\\.[a-zA-Z0-9]+$)/Uisx", nn44[1][k], nn)) {
                url = nn44[1][k];
                if(nn44.length>2) title = nn44[2][k];
            } else {
                if(nn44.length>2) url = nn44[2][k];
                title = nn44[1][k];
            }
            var hz="";
            if(nn44.length>3) hz = (!preg_match("/\\?/",url))?"?"+nn44[3][k]:"&"+nn44[3][k];
            if(fn.preg_match("/swf|flv/i",url)){
                tempstr += "[flash]"+fn.quanurl(url, thisurl, thisbaseurl)+hz+"[/flash]\r\n"+title+"\r\n";
            }else{
                tempstr+= "[media]"+fn.quanurl(url, thisurl, thisbaseurl)+hz+"[/media]\r\n"+title+"\r\n";
            }
        }
        tempstr = deletePublic(tempstr, thisurl, 0);
        returntextarea = (fn.maxlen(tempstr) > fn.maxlen(textarea)) ? tempstr : tempstr+"\r\n"+textarea;
        a = 1;
    }


    if (nn55.length>0&&nn55[1].length > 0) {
        tempstr = "";inarr=new Array();newnn55=new Array();
        for (k = 0; k < nn55.length; k++) {
            v=nn55[k];
            if(!is_int(k)){
                newnn55[0][ifhypy(k)]=v;
            }
        }
        for (k = 0; k < nn55[1].length; k++) {
            if(nn55['name'][k]!=""){
                name=nn55['name'][k];
                value=nn55['value'][k];
            }else{
                if(fn.is_array(nn55[2][k])&&nn55[2][k].length>0){
                    name = nn55[1][k];
                    value = nn55[2][k];
                }else{
                    nn=new Array();
                    if (fn.preg_match("/\\:|：|<(?:B|strong)>/Uisx", nn22[2][k], nn)) {
                        name = nn55[2][k];
                        value = nn55[1][k];
                    } else {
                        name = nn55[1][k];
                        value = nn55[2][k];
                    }
                    name = fn.utf8encode(name);
                    value = fn.utf8encode(value);
                }
            }
            name=ifhypy(clzdname($name));
            if(fn.in_array(name,knarr)){
                continue;
            }else{
                knarr.push(name);
            }
            value=clzdvalue(value);
            if(value!=""&&name!=""){
                tempstr+="\r\n"+name+":".$value;
            }
            newnn55[0][name]=value;
        }
        //GLOBALS['nn55']=newnn55;
        tempstr = deletePublic(tempstr, thisurl, 0);
        returntextarea = tempstr+"\r\n"+textarea;
        a = 1;
    }

    if (nn11.length>0&&nn11[1].length > 0) {
        var returntextarea="";
        for (i = 0; i < nn11[1].length; i++) {
            nr = nn11[1][i];
            nr = fn.preg_replace("/_small\\.jpg/Uisx", ".jpg", nr);
            nr = fn.preg_replace("/thumb_[0-9]+_[0-9]+_/Uisx", "", nr);
            if (fn.trim(nr) != "") {
                if (fn.preg_match("/\\.(jpg|png|gif|jpeg)\\s*(?<!html|htm)$/i", nr)) {
                    returntextarea = "\r\n" + fn.trim(createimgubb(nr, title, rs.loadimg, thisurl, thisbaseurl)) + "\r\n" + returntextarea;
                } else {
                    returntextarea = deletePublic(nr, thisurl, 0) + "\r\n" + returntextarea;
                }
            }
        }
        returntextarea=textarea+returntextarea;
    }

    if (nn111.length > 0) {
        returntextarea="";
        for (i = 0; i < nn111.length; i++) {
            nr = nn111[i];
            nr = fn.preg_replace("/_small\\.jpg/Uisx", ".jpg", nr);
            nr = fn.preg_replace("/thumb_[0-9]+_[0-9]+_/Uisx", "", nr);
            if (fn.trim(nr) != "") {
                if (preg_match("/\\.(jpg|png|gif|jpeg)\\s*$/i", nr)) {
                    returntextarea+= "\r\n"+ fn.trim(createimgubb(nr, title, rs.loadimg,thisurl, thisbaseurl))+ "\r\n\r\n"+nn222[k]+ "\r\n";
                } else {
                    returntextarea+= "\r\n" + fn.trim(createimgubb(nn222[k], title,rs.loadimg, thisurl, thisbaseurl)) + "\r\n"+ fn.clwz(fn.strip_tags(nr))+"\r\n\r\n";
                }
            }
        }
    }

    if (nn99.length>0&&nn99[1].length > 0) {
        //echo quanurl(nn99[1][0],$thisurl)."\r\n";
        nr = redo(fn.quanurl(nn99[1][0], thisurl, thisbaseurl), thissecexe);
        if (trim(nr) != "") returntextarea+= nr;
    }

    textarea = returntextarea;
    return returntextarea;
}

function createimgubb(url, title, loadimg, thisurl, thisbaseurl)
{
    var title2 = fn.utf8encode(title);
    textarea="";
    if (url != "") {
        url=fn.str_replace("\\","",url);
        //url=fn.preg_replace("/(?<!http\\:)\/\//Uisx","/",url);
        url=fn.preg_replace("/http:\\/{2,}/isx","http://",url);
        if (loadimg) {
            url = fn.str_replace("%", "BAIFENHAO", url);
            textarea= "[img]http://collect.longsunhd.com/source/plugin/yzs1013_pldr/getimg.php?url=" +fn.surlencode(fn.quanurl(fn.trim(url), thisurl, thisbaseurl)) + "[/img]";
        } else {
            textarea= "[img]"+ fn.quanurl(fn.trim(url), thisurl, thisbaseurl) + "[/img]";
        }
    }

    if(fn.preg_match("/^http\:\/\//Uisx",title)){
        textarea= fn.trim(textarea)+"\r\n[url="+title+"]"+title2+"[/url]\r\n";
    }else{
        textarea= "\r\n"+textarea+"\r\n"+title2+"\r\n";
    }
    return textarea;
}



